<template>
  <view class="caiku-box">
    <view v-if="showCai" class="caiku-item-show">
      <image class="yuanbao-img" mode="widthFix" src="@/static/images/bazi/yuanbao.png" />
      <view class="yuanbao-txt">财</view>
    </view>
    <view v-if="isCaixing" class="caiku-item">
      <image class="yuanbao-img" mode="widthFix" src="@/static/images/bazi/yuanbao.png" />
      <view class="yuanbao-txt">财</view>
    </view>
    <view v-if="isCaiku" class="caiku-item">
      <image class="yuanbao-img" mode="widthFix" src="@/static/images/bazi/yuanbao.png" />
      <view class="yuanbao-txt">库</view>
    </view>
  </view>
</template>
<script>
  import { caikuCalc } from './js/bazi.js'
  export default {
    props: {
      ganzhi: {
        type: String,
        default: ""
      },
      riyuan: {
        type: String,
        default: ""
      },
      showCai: {
        type: Boolean,
        default: false
      }
    },
    data() {
      return {
        isCaixing: false,
        isCaiku: false
      }
    },
    watch: {
      ganzhi() {
        this.change()
      }
    },
    methods: {
      change() {
        let result = caikuCalc(this.ganzhi, this.riyuan);
        this.isCaixing = result.isCaixing;
        this.isCaiku = result.isCaiku;
      }
    }
  };
</script>

<style lang="scss" scoped>
  .caiku-box {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }
  .caiku-item-show {
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  .caiku-item {
    display: flex;
    flex-direction: row;
    align-items: center;
  }
  .yuanbao-img {
    width: 22rpx;
    height: 17rpx;
    margin-right: 4rpx;
  }
  .yuanbao-txt {
    color: #D5C3A5;
    font-weight: bold;
    font-size: 20rpx;
    line-height: 24rpx;
  }
</style>